package com.tc.vms.producer;

import com.tc.vms.MessageWrap;
import com.tc.vms.SLA;
import com.tc.vms.connection.VmsConnectionManager;
import com.tc.vms.encoding.Message;
import com.tc.vms.exception.VmsClientException;
import com.tc.vms.iface.IContext;
import com.tc.vms.iface.IPublisher;
import com.tc.vms.iface.TransactionMessageListener;

/**
 * Created by yonghua.zhang on 2016/1/7.
 */
public abstract class AbstractPublisher implements IPublisher {
    protected final static ThreadLocal<Message.VMSMessage.Builder> vmsBuilderLocal = new ThreadLocal<Message.VMSMessage.Builder>() {

        @Override
        protected Message.VMSMessage.Builder initialValue() {
            return Message.VMSMessage.newBuilder();
        }
    };

    protected final static ThreadLocal<Message.KeyPair.Builder> vmsKeyBuilderLocal = new ThreadLocal<Message.KeyPair.Builder>() {

        @Override
        protected Message.KeyPair.Builder initialValue() {
            return Message.KeyPair.newBuilder();
        }
    };

    protected volatile boolean isOpen = false;
    protected final VmsConnectionManager vmsConnectionManager;
    protected final VmsProducerProxy vmsProducerProxy;
    protected final PubQoS pubQoS;
    protected final SLA serviceSLA;

    protected AbstractPublisher(VmsProducerProxy vmsProducerProxy, VmsConnectionManager vmsConnectionManager) {
        this.vmsConnectionManager = vmsConnectionManager;
        this.vmsProducerProxy = vmsProducerProxy;
        pubQoS = vmsProducerProxy.getQos();
        serviceSLA = vmsProducerProxy.getSLA();
    }

    @Override
    public void suspend() {

    }

    @Override
    public void resume() {

    }

    @Override
    public SLA slaOption() {
        return null;
    }

    /*@Override
    public PubQoS qosOption() {
        return null;
    }*/

    @Override
    public SendResult sendMessage(MessageWrap message) throws VmsClientException {
        return null;
    }

    @Override
    public SendResult sendMessageByOrder(MessageWrap message, String partKey) throws VmsClientException {
        return null;
    }

    @Override
    public SendResult sendTransactionMessage(MessageWrap message, TransactionMessageListener listener) throws VmsClientException {
        return null;
    }

    @Override
    public boolean init(IContext context) throws VmsClientException {
        return false;
    }

    @Override
    public boolean start() throws VmsClientException {
        return false;
    }

    @Override
    public void shutdown() {

    }
}
